#define _CRT_SECURE_NO_WARNINGS 1

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 5010;
ll a[N];

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll x; cin >> x;
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	if (n==0) {
		cout << "0 0" << endl;
		return 0;
	}
	sort(a + 1, a + n + 1);
	ll mn=0, mx=0;
	for (int i = 1; i <= n; i++) {
		mn = max(min(a[i], x + 1 - a[i]),mn);
	}
	mx = max(a[n], x + 1 - a[1]);
	cout << mn << " " << mx << endl;
	return 0;
}